package com.dailyblue.java.spring.boot.mvc.mybatis.mapper;

import com.dailyblue.java.spring.boot.commons.bean.Section;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Set;

@Mapper
public interface SectionMapper {
    @Select("select * from section where state=1")
    List<Section> findAllSection();
    @Select("select * from section where state=1 and id=#{id}")
    @Results({
            @Result(property = "id",column = "id",id = true),
            @Result(property = "postSet",column = "id",javaType = Set.class,
                    many = @Many(select = "com.dailyblue.java.spring.boot.mvc.mybatis.mapper.PostMapper.findAllPostBySectionId"))
    })
    Section findSectionById(int id);

}
